//
//  ClearScene.cpp
//  client
//
//  Created by sunpeng on 8/14/15.
//
//

#include "ClearScene.h"
#include "CCFactory.h"
#include "LogoScene.h"
#include "AppDelegate.h"

USING_NS_CC;
DRAGONBONES_USING_NAME_SPACE;


Scene* ClearScene::createScene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::create();
    
    // 'layer' is an autorelease object
    auto layer = ClearScene::create();
    
    // add layer as a child to scene
    scene->addChild(layer);
    
    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool ClearScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    return true;
}

void ClearScene::onEnterTransitionDidFinish()
{
    CCLOG("ClearScene onEnter");

    //延迟执行，等待清除干净
    Director::getInstance()->getScheduler()->schedule([](float delta){
        CCFactory::getInstance()->clear();
        AppDelegate::relaunchApp(false);
    }, this,0.1f,0,0.0f,false,"restart");
}
